<?php

namespace App\Http\Controllers\Common;

use App\Common\ResponseCode;
use App\Http\Controllers\BaseController;
use App\Params\Common\AlbumDeleteParams;
use App\Params\Common\AlbumEditParams;
use App\Params\Common\AlbumListParams;
use App\Service\Common\AlbumService;
use App\Params\Common\AlbumDetailParams;

class AlbumController extends BaseController
{
    public function list()
    {
        $param = AlbumListParams::create();

        $list = AlbumService::getInstance()->getList($param);

        return $this->success($list);
    }

    public function delete()
    {
        $param = AlbumDeleteParams::create();
        $ret = AlbumService::getInstance()->delete($param);
        if ($ret) {
            return $this->success();
        }
        return $this->fail(ResponseCode::FAIL);
    }

    public function edit()
    {
        $param = AlbumEditParams::create();
        $ret = AlbumService::getInstance()->edit($param);
        if ($ret) {
            return $this->success(['id' => $ret]);
        }
        return $this->fail(ResponseCode::FAIL);
    }

    /**
     * 专辑详情
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\BusinessException
     * Author:xsc
     * Time:2023/11/22 17:28
     */
    public function detail()
    {
        $params = AlbumDetailParams::create();
        $data = AlbumService::getInstance()->detail($params);
        return $this->success($data);
    }

    
}
